<template>
  <view class="foot-btn-groups" v-if="order.trade_status == 0 || order.trade_status == 2">
    <view
      class="confirm-btn"
      v-if="order.trade_status == 0"
      @click="handleConfirmBtn"
      >{{$t('order.confirmSend')}}</view
    >
		<view
		  class="confirm-btn"
		  v-if="order.trade_status == 2"
		  @click="handleConfirmBtn"
		  >{{$t('person.confirmCancle')}}</view
		>
  </view>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: {
    order: {
      type: Object,
      default: {},
    },
    showRefund: {
      type: Boolean,
      default: false,
    },
  },
  //   订单状态，-1:默认，0:待发货，1:已取消，2:已发货，3:已确认
  computed: {
    btnWordsDeal() {
      let cancleWord = "",
        confirmWord = "",
        deleteWord = "";
      if (this.order.trade_status == -1) {
        cancleWord = "取消订单";
        confirmWord = "去支付";
      }
      if (this.order.trade_status == 0) {
        cancleWord = "取消订单";
        confirmWord = "提醒发货";
      }
      if (this.order.trade_status == 1) {
        deleteWord = "删除订单";
        confirmWord = "";
      }
      if (this.order.trade_status == 2) {
        cancleWord = "取消订单";
      }
      if (this.order.trade_status == 3) {
        deleteWord = "删除订单";
        if (this.showRefund) {
          cancleWord = "退换/售后";
        } else {
          cancleWord = "";
        }
        confirmWord = "再次购买";
      }

      return { cancleWord, confirmWord, deleteWord };
    },
  },
  methods: {
    handleCancleBtn() {
      this.$emit("handleCancleBtn", {
        id: this.order.order_id,
        status: this.order.trade_status,
        is_delivery: this.order.is_delivery,
        cancleWord: this.btnWordsDeal.cancleWord,
      });
    },
    handleConfirmBtn() {
      this.$emit("handleConfirmBtn", {
        id: this.order.order_id,
      });
    },
    handleDeleteBtn() {
      this.$emit("handleDeleteBtn", {
        id: this.order.order_id,
      });
    },
  },
};
</script>

<style lang="scss"scoped>
.foot-btn-groups {
  width: 100%;
  height: calc(99rpx + env(safe-area-inset-bottom));
  background: #ffffff;
  border: 2rpx solid #f0f0f0;
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 12;
  padding-right: 35rpx;
  display: flex;
  justify-content: flex-end;
  padding-top: 20rpx;

  view {
    width: 152rpx;
    height: 60rpx;
    background: #ffffff;
    border-radius: 30rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24rpx;
    font-weight: 500;
  }

  .cancle-btn {
    color: #262626;
    margin-right: 24rpx;
    border: 1rpx solid #8e8e8e;
  }

  .confirm-btn {
    background: linear-gradient(90deg, #f2140c, #f14c0c);
    color: #ffffff;
  }
}
</style>
